// pages/user/user.js
var util = require('../../utils/util.js');
var Promise = require('../../utils/bluebird.min.js');
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    theratersMovieList: [],
    comingMovieList: []
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    util.getMovieList("/v2/movie/in_theaters", "看过", { count: 3 }).then((theratersMovieListdata) => {
      util.getMovieList("/v2/movie/coming_soon", "想看", { count: 3 }).then((comingMovieListdata) => {
         that.setData({
           theratersMovieList: util.movieDataFactory(theratersMovieListdata),
           comingMovieList: util.movieDataFactory(comingMovieListdata)
          });
      })
    })
    app.getUserInfo(function (userInfo) {
      that.setData({
        userInfo: userInfo
      })
    })
  },
})